#include "stdafx.h"
#include "CMDLine.h"

void PrintUsage(char* exePath)
{
	std::cout << "Creates self signed X.509 certificate. By Janis Bisenieks." << std::endl << std::endl;
	std::cout << "USAGE: " << std::endl;
	std::cout << "  " << getExeName(exePath) << " /gen <file> <serial#> <CN> <O> <C> <startDate> <endDate>" << std::endl;
	std::cout << std::endl;
	std::cout << "\t<file>      - Output file name for certificate" << std::endl;
	std::cout << "\t<serial#>   - Serial number for certificate" << std::endl;
	std::cout << "\t<CN>        - Common name" << std::endl;
	std::cout << "\t<O>         - Issuer's organization" << std::endl;
	std::cout << "\t<C>         - Issuer's country code" << std::endl;
	std::cout << "\t<startDate> - First date certificate valid (YYYY-MM-DD hh:mm:ss)" << std::endl;
	std::cout << "\t<endDate>   - Last day certificate valid (YYYY-MM-DD hh:mm:ss)" << std::endl << std::endl;;
};

std::string getExeName(char* exePath)
{
	int p = 0;
	std::string name;

	for(int i=strlen(exePath); i > 0; i--)
	{
		if(exePath[i] == '\\')
		{
			p = i + 1;
			break;
		};
	};

	name = exePath + p;

	return name;
};

